import request from '@/utils/request'

// 文件上传，返回文件访问路径
export function uploadFile(file) {
  const formData = new FormData()
  formData.append('file', file)
  return request({
    url: '/api/upload',
    method: 'post',
    data: formData,
    // 让浏览器自动设置 multipart 边界
    headers: { 'Content-Type': undefined }
  })
}

// 语音转文本，传入文件URL
export function translateAudio(fileUrl) {
  return request({
    url: '/api/translation',
    method: 'get',
    params: { fileUrl }
  })
}

// 文本转语音
export function synthesizeTTS(text, voice, language, roleId) {
  return request({
    url: '/api/tts/synthesize',
    method: 'post',
    params: {
      text,
      voice,
      language,
      roleId
    }
  })
}

// 获取音频URL
export function getAudioUrl(text, voice, language, roleId) {
  return request({
    url: '/api/tts/audio/url',
    method: 'get',
    params: {
      text,
      voice,
      language,
      roleId
    }
  })
}